|
|
|
|
|
|
|
To accomplish all this, you need three forms, three standard code modules, and one class module: |
|
|
|
|
|
|
|
|
· SQLVBMain: An MDI form to enclose all activity. |
|
|
|
|
|
|
|
|
· SQLVBChild: A child form that displays the result sets. |
|
|
|
|
|
|
|
|
· SQLVBAbout: A simple form that displays the About box. |
|
|
|
|
|
|
|
|
·SQLVBMOD: A Visual Basic code module that contains all the methods for interpreting an SQL-VB5 script. |
|
|
|
|
|
|
|
|
·SQLVBGEN: A Visual Basic code module that contains all the methods for generating an SQL-VB5 script from the existing MDB. |
|
|
|
|
|
|
|
|
·SQLVBCLASS: A Visual Basic code module that contains the primary startup routine (Main). |
|
|
|
|
|
|
|
|
·Application: A Visual Basic class module that encapsulates the object model interface. |
|
|
|
|
|
|
|
|
The SQLVBMain form needs some menu items and a CommonDialog control to handle the Open File dialog that runs the SQL scripts. The SQLVBChild form needs a Data control and a DBGrid control to handle the result sets. The SQLVBAbout needs a couple of Label controls and a single OK command button. |
|
|
|
|
|
|
|
|
The SQLVBMOD code module needs three main routines and a host of supporting routines. The three main routines are |
|
|
|
|
|
|
|
|
·SQLFileOpen: To open the ASCII file selected by the user. |
|
|
|
|
|
|
|
|
·SQLFileProcess: To process the SQL commands in the file. |
|
|
|
|
|
|
|
|
·SQLFileClose: To safely close the ASCII file upon completion. |
|
|
|
|
|
|
|
|
The SQLVBMOD needs an error routine; some special routines to handle the database OPEN, CLOSE, and CREATE commands; a routine to handle the SQL DML commands (SELECT_FROM); and a routine to handle the SQL DDL commands (CREATE TABLE, for example). You can add these as you go along. |
|
|
|
|
|
|
|
|
The SQLVBGEN module needs routines to read the selected MDB and then write out the SQL-Visual Basic code that represents the tables, fields, indexes, and relationships defined in the MDB. It also has a handful of routines to handle script headers and footers, comment lines, and saving the finished script to the disk. |
|
|
|
|
|
|
|
|
The SQLVBCLASS module has a single Sub Main() used to start the application. |
|
|
|
|
|
|
|
|
The application class module has the properties and methods needed to allow external VBA programs to access and run SQLVB methods. Other programs can create their own instance of SQL-VB5 and then run all the primary commands. The object model for SQL-VB5 is described in Figure A.1 and Table A.1. |
|
|
|
|
|